/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (CCamera - 3D Camera Class)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson 	<B00137077@studentmail.uws.ac.uk>
*				John Gray 			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop 		<B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/

#include "CCamera.h"

template<> CCamera * CSingleton< CCamera >::m_pSingleton = 0;

void CCamera::setXPosition(GLfloat newCameraXPosition)
{
	// sets the X position of the camera to the new position passed in the parameter
	this->cameraXPosition = newCameraXPosition;
}

void CCamera::setYPosition(GLfloat newCameraYPosition)
{
	// sets the Y position of the camera to the new position passed in the parameter
	this->cameraYPosition = newCameraYPosition;
}

void CCamera::setZPosition(GLfloat newCameraZPosition)
{
	// sets the Z position of the camera to the new position passed in the parameter
	this->cameraZPosition = newCameraZPosition;
}

void CCamera::setXRotation(GLfloat distanceRotatedOnXAxis)
{
	// Adds the value passed in the parameter to the current X rotation
	this->cameraXRotation += distanceRotatedOnXAxis;
}

void CCamera::setYRotation(GLfloat distanceRotatedOnYAxis)
{
	// Adds the value passed in the parameter to the current Y rotation
	this->cameraYRotation += distanceRotatedOnYAxis;
}

void CCamera::setZRotation(GLfloat distanceRotatedOnZAxis)
{
	// Adds the value passed in the parameter to the current Z rotation
	this->cameraZRotation += distanceRotatedOnZAxis;
}

void CCamera::init(GLfloat cameraXPosition, GLfloat cameraYPosition, GLfloat cameraZPosition, GLfloat cameraXRotation, GLfloat cameraYRotation, GLfloat cameraZRotation)
{
	// set the initial values for the position and rotation of the camera
	this->cameraXPosition = cameraXPosition;
	this->cameraYPosition = cameraYPosition;
	this->cameraZPosition = cameraZPosition;
	this->cameraXRotation = cameraXRotation;
	this->cameraYRotation = cameraYRotation;
	this->cameraZRotation = cameraZRotation;
}

void CCamera::update(GLfloat cameraXPosition, GLfloat cameraYPosition, GLfloat cameraZPosition, GLfloat cameraXRotation, GLfloat cameraYRotation, GLfloat cameraZRotation)
{
	// Update the camera as you move it using the keybinds in the main program class
	glRotatef(cameraXRotation, 1.0, 0.0, 0.0);
	glRotatef(cameraYRotation, 0.0, 1.0, 0.0);
	glRotatef(cameraZRotation, 0.0, 0.0, 1.0);
	glTranslatef(-cameraXPosition, -cameraYPosition, -cameraZPosition);
}


